<template>
  <el-dialog
    v-el-drag-dialog
    title="积分合并"
    :visible.sync="visible"
    width="1024px"
    @closed="reset"
  >
    <el-form ref="dataForm" class="form" :model="temp" label-position="right" label-width="70px">
      <el-form-item label="客户电话" prop="csmPhone">
        <el-input v-model="temp.csmPhone" placeholder="请输入">
          <el-button slot="append" class="append-search">查询</el-button>
        </el-input>
      </el-form-item>
      <el-form-item label="客户名称" prop="csmName">
        <el-input v-model="temp.csmName" disabled />
      </el-form-item>
      <el-form-item label="当前积分" prop="scores">
        <el-input v-model="temp.scores" disabled />
      </el-form-item>
      <el-form-item label="冲正积分" prop="addScores">
        <el-input v-model="temp.addScores" disabled />
      </el-form-item>
      <el-form-item prop="remark" class="block">
        <label slot="label">备&emsp;&emsp;注</label>
        <el-input v-model="temp.remark" type="textarea" :rows="3" maxlength="255" show-word-limit />
      </el-form-item>
    </el-form>
    <div class="info-title">
      <span class="title-icon" />
      <span>客户信息</span>
    </div>
    <lb-table
      ref="lbTable"
      border
      :column="tableData.column"
      :data="tableData.data"
      :pagination="false"
    />
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">
        关闭
      </el-button>
      <el-button :loading="$loadingPlugin.add" type="primary" @click="success">
        保存
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { } from '@/api'

  export default {
    name: 'scores-merge',
    data() {
      return {
        visible: false,
        temp: {
          csmPhone: '',
          csmName: '',
          scores: '',
          addScores: '',
          remark: ''
        },
        tableData: {
          total: 0,
          column: [
            {
              type: 'selection'
            },
            {
              prop: 'name',
              label: '角色名称',
              width: 110
            },
            {
              prop: 'code',
              label: '角色编码',
              width: 110
            },
            {
              prop: 'createUser',
              label: '创建人',
              width: 110
            },
            {
              prop: 'remark',
              label: '备注'
            },
            {
              prop: 'name',
              label: '角色名称',
              width: 110
            },
            {
              prop: 'code',
              label: '角色编码',
              width: 110
            },
            {
              prop: 'createUser',
              label: '创建人',
              width: 110
            },
            {
              prop: 'remark',
              label: '备注'
            }
          ],
          data: [{
            name: '李三',
            code: 'aabcsd',
            createUser: '007',
            remark: 'sadfasdfasdfasdfsad'
          }, {
            name: '李三',
            code: 'aabcsd',
            createUser: '007',
            remark: 'sadfasdfasdfasdfsad'
          }, {
            name: '李三',
            code: 'aabcsd',
            createUser: '007',
            remark: 'sadfasdfasdfasdfsad'
          }]
        }
      }
    },
    methods: {
      open(temp) {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          if (temp) {
            this.temp = Object.assign(this.temp, temp)
          }
        })
      },
      success() {
        this.$refs.dataForm.validate(valid => {
          if (!valid) return
        })
      },
      async add() {
        this.resolve()
        this.visible = false
        this.$notify({
          title: '提示',
          message: '新增成功',
          type: 'success',
          duration: 2000
        })
      },
      reset() {
        this.temp = {
          csmPhone: '',
          csmName: '',
          scores: '',
          addScores: '',
          remark: ''
        }
        this.$nextTick(() => {
          this.$refs.dataForm.clearValidate()
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .form {
    display: flex;
    flex-wrap: wrap;
    & /deep/ .el-form-item {
      width: 50%;
      padding-right: 10px;
      .el-form-item__content > .el-select {
        width: 100%;
      }
    }
    .block {
      width: 100%;
    }
  }
  .info-title {
    display: flex;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 20px;
    .title-icon {
      display: inline-block;
      width: 4px;
      height: 18px;
      margin-right: 6px;
      background: $themeColor;
    }
    span {
      font-weight: 700;
      color: $themeColor;
    }
  }
</style>
